home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / python2.4 / site-packages / pygtk.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2006-01-20  |  2KB  |  61 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.4)
  3.  
  4. import fnmatch
  5. import glob
  6. import os
  7. import sys
  8. __all__ = [
  9.     'require']
  10. _pygtk_dir_pat = 'gtk-[0-9].[0-9]'
  11. _pygtk_required_version = None
  12.  
  13. def _get_available_versions():
  14.     versions = { }
  15.     for dir in sys.path:
  16.         if not dir:
  17.             dir = os.getcwd()
  18.         
  19.         if not os.path.isdir(dir):
  20.             continue
  21.         
  22.         if fnmatch.fnmatchcase(os.path.basename(dir), _pygtk_dir_pat):
  23.             continue
  24.         
  25.         for filename in glob.glob(os.path.join(dir, _pygtk_dir_pat)):
  26.             pathname = os.path.join(dir, filename)
  27.             if not os.path.isdir(pathname):
  28.                 continue
  29.             
  30.             if not os.listdir(pathname):
  31.                 continue
  32.             
  33.             if not versions.has_key(filename[-3:]):
  34.                 versions[filename[-3:]] = pathname
  35.                 continue
  36.         
  37.     
  38.     return versions
  39.  
  40.  
  41. def require(version):
  42.     global _pygtk_required_version
  43.     if _pygtk_required_version != None:
  44.         if not _pygtk_required_version == version:
  45.             raise AssertionError, 'a different version of gtk was already required'
  46.         return None
  47.     
  48.     if not not sys.modules.has_key('gtk'):
  49.         raise AssertionError, 'pygtk.require() must be called before importing gtk'
  50.     versions = _get_available_versions()
  51.     if not versions.has_key(version):
  52.         raise AssertionError, "required version '%s' not found on system" % version
  53.     for dir in sys.path:
  54.         if fnmatch.fnmatchcase(os.path.basename(dir), _pygtk_dir_pat):
  55.             sys.path.remove(dir)
  56.             continue
  57.     
  58.     sys.path.insert(0, versions[version])
  59.     _pygtk_required_version = version
  60.  
  61.